<!DOCTYPE html>
<html>
		<head>
			<meta charset="utf-8">
			<title></title>
			<script src="../js/utils.js" type="text/javascript" charset="utf-8"></script>
			<style type="text/css">
				*{margin: 0;
				  padding: 0;
				 }
				div{
					width: 300px;
					height: 250px;
					position: absolute;
					top: 0;
					bottom: 0;
					left: 0;
					right: 0;
					margin: auto;
					border: 1px solid orangered;
					padding: 20px;
				}
				div h2{
					color: #FF4500;
				}
				div form p{
					font-size: 16px;
					margin:10px 0;
				}
				div form p input{
					outline: none;
					margin: 10px;
				}
				div form .button{
					float: right;
					
				}
				div form .button button{
					width: 100px;
					height: 30px;
					color: #fff;
					background-color: cornflowerblue;
					outline: none;
					border: none;
					cursor: pointer;
					border-radius: 10px;
				}
			</style>
		</head>
	</head>
	<body>
        <div>
			<h2>注&nbsp;&nbsp;册</h2>
			<form >
				<p>用户名：<input type="text" name="name" id="name"  /></p>
				<p style="margin-left: 15px;">密码：<input type="password" name="pwd" id="pwd"  /></p>
				<p class="button"><button>注册</button></p>
			</form>
		</div>
		<script type="text/javascript">
			var form=document.querySelector("form")
			var nameInput = document.querySelector('#name')
			var pwdInput = document.querySelector('#pwd')
			
			form.onsubmit=function(){
				const name=nameInput.value
				const pwd=pwdInput.value
				
			 utils.post("../api/user/register.php",{name,pwd},resp=>{
					if(resp.code===200){
						alert(resp.body.msg+"即将跳转登录界面")
						location.href='login.html'
					}else{
						alert(resp.body.msg)
					}
				})
				return false
			}
		</script>
	</body>
</html>
